package com.csxy.six.controller;

import com.csxy.six.R;
import com.csxy.six.R2;
import com.csxy.six.entity.Blacklist;
import com.csxy.six.entity.LoginLog;
import com.csxy.six.service.BlacklistService;
import com.csxy.six.service.LoginLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin")
@Tag(name = "管理员控制器", description = "管理员专用接口，包含黑名单和登录日志管理")
public class AdminController {

    @Autowired
    private BlacklistService blacklistService;

    @Autowired
    private LoginLogService loginLogService;

    @GetMapping("/blacklist")
    @Operation(summary = "获取黑名单列表", description = "获取系统中所有的黑名单记录")
    public R2<List<Blacklist>> getAllBlacklist() {
        List<Blacklist> list = blacklistService.list();
        return R2.ok(list);
    }

    @GetMapping("/login-logs")
    @Operation(summary = "获取登录日志", description = "获取系统中所有的用户登录日志")
    public R2<List<LoginLog>> getLoginLogs() {
        List<LoginLog> list = loginLogService.list();
        return R2.ok(list);
    }
}